<?php

use Phinx\Migration\AbstractMigration;
use Phinx\Db\Adapter\MysqlAdapter;
class IntergralDetail extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function up()
    {
        $table = $this->table('integral_detail',array('comment' => '旅行币流水表'));
        $table
              ->addColumn('user_id', 'integer', array('comment' => '会员id','limit' => MysqlAdapter::INT_REGULAR,'null' => true))
              ->addColumn('type', 'string', array('limit' => 255,'null' => true))
              ->addColumn('intergrate', 'string', array('limit' => 255,'null' => true))
              ->addColumn('branch_id', 'string', array('limit' => 255,'comment' => '分公司名称','null' => true))
              ->addColumn('camp_id', 'integer', array('limit' => MysqlAdapter::INT_TINY,'comment' => '营地名称','null' => true))
              ->addColumn('remark', 'string', array('limit' => 255,'comment' => '备注信息','null' => true))
              ->addColumn('created_at', 'timestamp', array('default' => 'CURRENT_TIMESTAMP'))
              ->addColumn('updated_at', 'timestamp', array('null' => true))
              ->addIndex('id')
              ->save();   
    }
    public function down()
    {
        $this->dropTable('integral_detail');
    }
}
